<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>添加（编辑）运费模板</title>
<link href="__PUBLIC__/admin/css/xc.min.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/admin/css/xc.admin.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/lib/iconfont/iconfont.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/lib/uploadify/uploadify.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/xc.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/xc.admin.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/common-1.0.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/layer/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/My97DatePicker/WdatePicker.js"></script>
<script src="__PUBLIC__/lib/uploadify/jquery.uploadify.min.js"></script> 
<style type="text/css">
#file_upload{ float:right}
#file_upload-queue{ display:none}
</style>
</head>
<body>
<div class="pd-10">
  <form action="" method="post" class="form form-horizontal" id="myform" enctype="multipart/form-data">
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>首重：</label>
      <div class="formControls col-8">
        <input type="text" class="input-text" placeholder="请输入最低的计费重量" id="firstHeavy" name="firstHeavy" value="{$ure.fr_first_heavy}">
      </div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>首费：</label>
      <div class="formControls col-8">
        <input type="text" class="input-text" placeholder="请输入最低收费" id="firstPrice" name="firstPrice" value="{$ure.fr_first_price}">
      </div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>续重：</label>
      <div class="formControls col-8">
        <input type="text" class="input-text" placeholder="请输入续重重量" id="addHeavy" name="addHeavy" value="{$ure.fr_add_heavy}">
      </div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>续费：</label>
      <div class="formControls col-8">
        <input type="text" class="input-text" placeholder="请输入续费金额" id="addPrice" name="addPrice" value="{$ure.fr_add_price}">
      </div>
    </div>
     <div class="row cl">
	  <label class="form-label col-2"><span class="c-red">*</span>运送到：</label>
	  <div class="formControls col-9">
        <foreach name="regList" item="region" key="kk">	
          <dl class="permission-list">
            <dt><label><input type="checkbox" name="right[]" value="{$region[re_id]}" cka="mod-{$kk}" <if condition="($region[enable] eq 1)">checked <elseif condition="($region[disabled] eq 1)" />disabled</if> > {$region[re_name]}</label></dt>
            <dd>
              <dl class="cl permission-list2">
                <dd>
                  <foreach name="region.child" item="vv" key="ii">
                    <label><input type="checkbox" name="right[]" value="{$vv.re_id}" ck="mod-{$kk}" <if condition="($vv[enable] eq 1)">checked <elseif condition="($vv[disabled] eq 1)" />disabled</if> >{$vv.re_name}</label>
                  </foreach>
                </dd>
              </dl>
            </dd>
          </dl>
        </foreach>
      </div>
    </div>
    <div class="row cl">
      <div class="col-9 col-offset-3">
        <input type="hidden" id="fid" name="fid" value="{$ure.fr_id}">
        <input type="hidden" id="act" name="act" value="{$act}">
        <button type="button" id="sub" name="sub" class="btn btn-primary radius" onClick="checkSubmit()"><i class='Hui-iconfont'>&#xe632;</i> 保存</button>
        <input class="btn btn-default radius" type="button" onClick="layer_close();" value="取消"/>
      </div>
    </div>
  </form>
</div>
<script type="text/javascript">
$(document).ready(function(){
	$(":checkbox[cka]").click(function(){
		var $cks = $(":checkbox[ck='"+$(this).attr("cka")+"']");
		if($(this).is(':checked')){
			$cks.each(function(){$(this).prop("checked",true);});
		}else{
			$cks.each(function(){$(this).removeAttr('checked');});
		}
	});
});
//按回车件触发提交
document.onkeydown=function(event){
	var e = event || window.event || arguments.callee.caller.arguments[0];
	if(e && e.keyCode==13){ // enter 键
		checkSubmit();
	}
}; 
//提交数据
function checkSubmit(){
	var firstHeavy = $.trim($('#firstHeavy').val());
	var firstPrice = $.trim($('#firstPrice').val());
	var addHeavy = $.trim($('#addHeavy').val());
	var addPrice = $.trim($('#addPrice').val());
	if(firstHeavy == ''){
		layer.msg('首重', {icon: 2});
		return false;
	}if(firstPrice == ''){
		layer.msg('首费不能为空!', {icon: 2});
		return false;
	}if(addHeavy == ''){
		layer.msg('续重不能为空!', {icon: 2});
		return false;
	}if(addPrice == ''){
		layer.msg('续费不能为空!', {icon: 2});
		return false;
	}
	$.ajax({
		type : 'post',
		url : '__MODULE__/Setup/freightAddEdit',
		data : $("#myform").serialize(),
		dataType : 'json',
		success : function(res){
			if(res.status == 1){
				layer.msg(res.msg,{icon:1,time:2000},function(){
					// 先获取窗口索引，才能关闭窗口  
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
				});
				parent.call_back_fun('success');
			}else{
				layer.msg(res.msg, {icon: 2});
			}
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			layer.alert('网络失败，请刷新页面后重试',{icon:2});
		}
	})
}
</script> 
</body>
</html>